package com.dwjm.goods;

import com.dwjm.CommonResult;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.Arrays;

@WebServlet("/deleteBatchGoods")
public class DeleteBatchGoodsServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");

        String[] ids = req.getParameterValues("ids");
        System.out.println("接收到的商品ID数组: " + Arrays.toString(ids));// 注意这里是 ids[]

        if (ids == null || ids.length == 0) {
            resp.getWriter().write("N");
            return;
        }

        GoodDao goodDao = new GoodDaolpml(); // 确保拼写没错
        boolean success = goodDao.batchDownGoods(ids);

        resp.getWriter().write(success ? "Y" : "N");
    }
}